<?php
namespace App\Http\Forms;

use App\Library\OSS;
use Kris\LaravelFormBuilder\Form;

class GiftForm extends Form
{
    public function buildForm()
    {
        $this
            ->add('shop_id', 'select', [
                'attr'  => ['class' => "form-control select2", 'id' => "shops-select"],
                'label' => "选择门店",
                'rules' => 'required|integer',
                'choices' => $this->getData('shops')??[],
            ])
            ->add('title', 'text', [
                'label' => "赠送包名",
                'rules' => 'required|string',
            ])
            ->add("package_id", 'select', [
                'attr' => ['class' => "form-control select2", 'multiple' => "multiple", 'id' => "package-select"],
                'label' => "适用范围",
                'rules' => 'nullable|array',
                'choices' => $this->getData('package')??[],
            ])
            ->add('content', 'include', [
                'label' => "赠品",
                'rules' => "required|array",
                'path' => "gift.content",
                'choices' => $this->getData('all')??[],
            ])
            ->add('submit', 'submit', [
                'attr' => ['class' => "form-control btn btn-success"],
                'label' => '保存',
            ]);
    }
}
